package com.xj.service;

import com.xj.dao.UserDAO;
import com.xj.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

  @Autowired
  private UserDAO userDAO;

  /**
   * 添加用户
   * @param user
   * @return
   */
  public int addUser(User user){
    return userDAO.addUser(user);
  }

  /**
   * 重载方法，根据用户邮箱查询用户
   * @param email
   * @return
   */
  public User getUser(String email) {
    return userDAO.selectByEmail(email);
  }

  /**
   * 重载方法，根据用户id查询用户
   * @param uid
   * @return
   */
  public User getUser(int uid) {
    return userDAO.selectById(uid);
  }
}
